package controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import beans.TeamMemberItemBean;
import sql.TeamMemberDao;

/**
 * Servlet implementation class GetProductOwnerForProject
 */
@WebServlet("/GetProductOwnerForProject")
public class GetProductOwnerForProject extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public GetProductOwnerForProject() {
        super();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		TeamMemberDao teamMemberDao = new TeamMemberDao();
		int projectId = Integer.parseInt(request.getParameter("projectId"));

		try {
			TeamMemberItemBean teamMemberItemBean = teamMemberDao.getProductOwner(projectId);
			PrintWriter out = response.getWriter();
			out.write(teamMemberItemBean.getJson());
		} catch (ClassNotFoundException | SQLException e) {
			e.printStackTrace();
		}
	}

}
